package com.bjpowernode.shop.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bjpowernode.shop.base.BaseStore;
import com.bjpowernode.shop.domain.Area;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/area")
public class AreaController extends BaseStore {
    
    @GetMapping("/listByPid")
    public ResponseEntity<List<Area>> listByPid(Long pid){
        return ResponseEntity.ok(
                areaService.list(
                        new LambdaQueryWrapper<Area>()
                                .eq(Area::getParentId,pid)
                )
        );
    }
    
    @GetMapping("/list")
    public ResponseEntity<List<Area>> list(){
        return ResponseEntity.ok(areaService.list());
    }
}
